home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / FLOATFRA.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  132 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.10  $
  6. //
  7. // Definition of class TFloatingFrame.
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_FLOATFRA_H)
  10. #define OWL_FLOATFRA_H
  11.  
  12. #if !defined(OWL_FRAMEWIN_H)
  13. # include <owl/framewin.h>
  14. #endif
  15. #if !defined(OWL_TINYCAPT_H)
  16. # include <owl/tinycapt.h>
  17. #endif
  18.  
  19. #if defined(BI_NAMESPACE)
  20. namespace OWL {
  21. #endif
  22.  
  23. // Generic definitions/compiler options (eg. alignment) preceeding the 
  24. // definition of classes
  25. #include <services/preclass.h>
  26.  
  27. //
  28. // class TFloatingFrame
  29. // ~~~~~ ~~~~~~~~~~~~~~
  30. // Implements a floating frame (owned popup frame w/ tiny caption)
  31. //
  32. // If there is a client window then the floating frame can shrink to fit
  33. // the client window leaving room for margins on the left, top, right, and
  34. // bottom
  35. //
  36. // If there is a client window then the floating palette expects the window
  37. // to paint its own background (and hence does nothing in response to the
  38. // WM_ERASEBKGND). If there is no client window then the floating palette
  39. // erases the client area background using TColor::SysUIFace
  40. //
  41. // If popupPalette is true then, dragFrame is enabled, styles are set to popup
  42. // with a tiny close box, and a border.
  43. //
  44. // When dragFrame mode is enabled the floating frame adds an extra non-client
  45. // margin around the outside to allow moving of the frame. This works well with
  46. // a thin frame and is nice when the client area is too full to allow dragging
  47. // from there.
  48. //
  49. class _OWLCLASS TFloatingFrame : public TFrameWindow, public TTinyCaption {
  50.   public:
  51.     TFloatingFrame(TWindow*        parent,
  52.                    const char far* title = 0,
  53.                    TWindow*        clientWnd = 0,
  54.                    bool            shrinkToClient = false,
  55.                    int             captionHeight = DefaultCaptionHeight,
  56.                    bool            popupPalette = false,
  57.                    TModule*        module = 0);
  58.  
  59.     void    SetMargins(const TSize& margin);
  60.     void    SetDragFrame(bool dragFrame);
  61.  
  62.     // Nameless union to declare a constant that is class scoped.
  63.     //
  64.     enum {
  65.       DefaultCaptionHeight = 58
  66.     };
  67.  
  68.   protected:
  69.     // Override TWindow & TFrameWindow virtuals
  70.     //
  71.     HWND    GetCommandTarget();
  72.     void    EvCommandEnable(TCommandEnabler& commandEnabler);
  73.     TResult EvCommand(uint id, HWND hWndCtl, uint notifyCode);
  74.  
  75.     // Event handler helper
  76.     //
  77.     TEventStatus  DoNCHitTest(TPoint& screenPt, uint& evRes);
  78.  
  79.     //      Event Handlers
  80.     //
  81.     void    EvSysCommand(uint cmdType, TPoint& p);
  82.     uint    EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS far& calcSize);
  83.     uint    EvNCHitTest(TPoint& screenPt);
  84.     bool    EvNCActivate(bool active);
  85.     uint    EvMouseActivate(THandle hTopLevel, uint hitCode, uint msg);
  86.     void    EvActivateApp(bool active, HTASK hTask);
  87. #if defined(BI_PLAT_WIN32)
  88.     void     EvNCPaint(HRGN);
  89. #else
  90.     void     EvNCPaint();
  91. #endif //BI_PLAT_WIN32
  92.  
  93.  
  94.   private:
  95.     TSize   Margin;       // Left and right, top and bottom
  96.     bool    DragFrame;    // True if frame edges are used to drag, not size window
  97.     bool    AppearActive; // Current fake-activation appearance flag
  98.  
  99.   DECLARE_RESPONSE_TABLE(TFloatingFrame);
  100.   DECLARE_STREAMABLE(_OWLCLASS, TFloatingFrame, 1);
  101. };
  102.  
  103. // Generic definitions/compiler options (eg. alignment) following the 
  104. // definition of classes
  105. #include <services/posclass.h>
  106.  
  107. #if defined(BI_NAMESPACE)
  108. } // namespace OWL
  109. #endif
  110.  
  111. //----------------------------------------------------------------------------
  112. // Inline implementations
  113. //
  114.  
  115. //
  116. // Set the margins for the client
  117. //
  118. inline void TFloatingFrame::SetMargins(const TSize& margin)
  119. {
  120.   Margin = margin;
  121. }
  122.  
  123. //
  124. // Set the flag for additional dragging area.
  125. //
  126. inline void TFloatingFrame::SetDragFrame(bool dragFrame)
  127. {
  128.   DragFrame = dragFrame;
  129. }
  130.  
  131. #endif  // OWL_FLOATFRA_H
  132.